<?php
require_once BaseUtil::getModulePath("base") . '/controllers/BaseController.php';
require_once BaseUtil::getModulePath('dbgrid') . '/DBGrid.php';
require_once BaseUtil::getModulePath("trade") . '/constants/TradeConstant.php';
require_once BaseUtil::getModulePath("trade") . '/constants/TradeLogConstant.php';

class Trade_TradelogController extends BaseController {
	public function init() {
		parent::init ();
	}
	
	public function indexAction() {
		$dbgrid = new DBGrid ( $this->view );
		$dbgrid->setPost ( $_POST );
		$dbgrid->addFilter ( DBGridConstant::FILTER_TYPE_TEXT, "u1-name", $this->_translate->translate ( "userName2" ));
		$dbgrid->addOptionsFilter ( DBGridConstant::FILTER_TYPE_SELECT, "account_agent_trade_logs-trade_type", $this->_translate->translate ( "tradeType" ), TradeLogConstant::getTypeList () );
		$dbgrid->addOptionsFilter ( DBGridConstant::FILTER_TYPE_SELECT, "account_agent_trade_logs-status", $this->_translate->translate ( "status" ), TradeConstant::getStatusList () );
		$dbgrid->addDateFilter ( "account_agent_trade_logs-created", $this->_translate->translate ( "createTime" ) );
		$dbgrid->addValueFilter ( 'account_agent_trade_logs-is_delete', '0' );
		$dbgrid->addFetchTable ( "account_agent_trade_logs", "*" );
		$dbgrid->addFetchTable ( "users as u1", "u1.name as user_name","u1.id = account_agent_trade_logs.user_id" );
		$dbgrid->addFetchColumn ( "sn", $this->_translate->translate ( "SN" ) );
		$dbgrid->addFetchColumn ( "user_name", $this->_translate->translate ( "userName2" ) );
		$dbgrid->addFetchColumn ( "trade_type", $this->_translate->translate ( "tradeType2" ), "", TradeLogConstant::getTypeList () );		
		$dbgrid->addFetchColumn ( "status", $this->_translate->translate ( "status2" ), "", TradeConstant::getStatusList () );
        $dbgrid->addFetchColumn ( "trade_sum", $this->_translate->translate ( "tradeSum2" ) );
        $dbgrid->addFetchColumn ( "account_balance_offset", $this->_translate->translate ( "accountBalanceOffset" ) );
        $dbgrid->addFetchColumn ( "balance_now", $this->_translate->translate ( "balanceNow" ));
        $dbgrid->addFetchColumn ( "account_debt_balance_offset", $this->_translate->translate ( "accountDebtOffset" ));
        $dbgrid->addFetchColumn ( "debt_now", $this->_translate->translate ( "debtNow" ) );
        $dbgrid->addFetchColumn ( "account_freeze_offset", $this->_translate->translate ( "accountFreezeOffset" ) );
        $dbgrid->addFetchColumn ( "freeze_now", $this->_translate->translate ( "freezeNow" ));     
        $dbgrid->addFetchColumn ( "account_usage_balance_offset",$this->_translate->translate ("accountUsageBalanceOffset"));
        $dbgrid->addFetchColumn ( "usage_balance_now", $this->_translate->translate ("usageBalanceNow"));             
		//$dbgrid->addFetchColumn ( "created", $this->_translate->translate ( "createDate" ) );
		$dbgrid->addFetchColumn ( "modified", $this->_translate->translate ( "updateDate" ) );
		//$dbgrid->addAAColAction ( "tradelog", "view", $this->_translate->translate ( "lookInfor" ), "detail.gif" );
		$dbgrid->setSortOrder ( "account_agent_trade_logs.modified", "DESC" );
		//$dbgrid->addAAModuleAction("tradelog","view",$this->_translate->translate("lookInfor"),"view");
		$dbgrid->setModule ( '/trade/tradelog' );
		$dbgrid->setPageTitle ( $this->_translate->translate ( "tradeLog" ) );
		$this->view->dbGrid = $dbgrid->render ();
	}
//	
//	public function viewAction() {
//		$id = $this->_getParam ( 'id' );
//		$tradeLogService = new TradeLogService ( );
//		$tradeLog = $tradeLogService->getTradeLogById ( $id );
//		$this->view->tradeLog = $tradeLog;
//	}
}